import SwiftUI
import Charts

struct Result: Identifiable {
    let id = UUID() // 
    let subject: String
    let score: Double
}

struct ChartWithObject: View {
    let results: Array<Result> = [
        Result(subject: "Math", score: 96.0),
        Result(subject: "English", score: 90),
        Result(subject: "Physics", score: 80),
        Result(subject: "Biological", score: 85),
        Result(subject: "Chemisty", score: 70)
    ]
    
    var body: some View {
        VStack {
            Text("Chart with Object")
                .font(.largeTitle)
            
            Chart {
                ForEach(results) { r in
                    BarMark(
                        x: PlottableValue.value("Labels", r.subject),
                        y: PlottableValue.value("Values", r.score)
                    )
                    .foregroundStyle(Color.green)
                }
            }
            .padding(.bottom, 100)
        }
        .padding()
    }
}
